package com.csjbot.weedle_auto.Slam.agent.Entity

import com.slamtec.slamware.geometry.PointF
import com.slamtec.slamware.geometry.Size
import com.slamtec.slamware.robot.Map
import java.io.Serializable
import java.util.*

/**
 * Created by chenqi on 2017/2/28.
 */

class MapBean : Serializable {
    val map: Map
        get() {
            val origin = PointF(map_origin_x, map_origin_y)
            val size = Size(map_size_width, map_size_height)
            val resolution = PointF(map_resolution_x, map_resolution_y)
            return Map(origin, size, resolution, timestamp, data!!)
        }


    var map_resolution_x: Float = 0.toFloat()
    var map_resolution_y: Float = 0.toFloat()
    var map_origin_x: Float = 0.toFloat()
    var map_origin_y: Float = 0.toFloat()
    var map_size_width: Int = 0
    var map_size_height: Int = 0

    /**
     * 虚拟轨道
     */
    var lines: List<MapLines>? = null


    /**
     * 虚拟墙
     */
    var walls: List<MapWalls>? = null


    /**
     * 构造函数
     *
     * @param map   获取地图对象
     * @param track
     */
    fun setMap(map: Map, walls: List<MapWalls>, track: List<MapLines>) {
        map_origin_x = map.origin.x
        map_origin_y = map.origin.y
        map_resolution_x = map.resolution.x
        map_resolution_y = map.resolution.y
        map_size_height = map.dimension.height
        map_size_width = map.dimension.width
        data = map.data
        timestamp = map.timestamp
        //固定版本号
        this.walls = walls
        lines = track
    }


    var timestamp: Long = 0
    var data: ByteArray? = null

    override fun toString(): String {
        return "MapBean{" +
                "map_resolution_x=" + map_resolution_x +
                ", map_resolution_y=" + map_resolution_y +
                ", map_origin_x=" + map_origin_x +
                ", map_origin_y=" + map_origin_y +
                ", map_size_width=" + map_size_width +
                ", map_size_height=" + map_size_height +
                ", timestamp=" + timestamp +
                ", data=" + Arrays.toString(data) +
                '}'
    }

    companion object {

        private const val serialVersionUID = 8711368828010083044L
    }
}
